<?php
/**
 * ForgotPass.php
 *
 * This page is for those users who have forgotten their
 * password and want to have a new password generated for
 * them and sent to the email address attached to their
 * account in the database. The new password is not
 * displayed on the website for security purposes.
 *
 * Note: If your server is not properly setup to send
 * mail, then this page is essentially useless and it
 * would be better to not even link to this page from
 * your website.
 *
 * Written by: Jpmaster77 a.k.a. The Grandmaster of C++ (GMC)
 * Last Updated: August 26, 2004
 */
include("include/session.php");
?>

<html>
<head>
	<title>movienight - forgot password</title>
	<link rel="stylesheet" href="css/bootstrap.min.css">
	<link rel="stylesheet" href="css/movienight.css">
</head>
<body>

<?php
/**
 * Forgot Password form has been submitted and no errors
 * were found with the form (the username is in the database)
 */
if(isset($_SESSION['forgotpass'])){
   /**
    * New password was generated for user and sent to user's
    * email address.
    */
   if($_SESSION['forgotpass']){
      echo "<h1>New Password Generated</h1>";
      echo "<p>Your new password has been generated "
          ."and sent to the email <br>associated with your account. "
          ."<a href=\"main.php\">Main</a>.</p>";
   }
   /**
    * Email could not be sent, therefore password was not
    * edited in the database.
    */
   else{
      echo "<h1>New Password Failure</h1>";
      echo "<p>There was an error sending you the "
          ."email with the new password,<br> so your password has not been changed. "
          ."<a href=\"main.php\">Main</a>.</p>";
   }
       
   unset($_SESSION['forgotpass']);
}
else{

/**
 * Forgot password form is displayed, if error found
 * it is displayed.
 */
?>

<h1>Forgot Password</h1>
<br><br>




		<form class="form-horizontal" action="process.php" method="POST">
			<fieldset>
				<?php $error = ($form->error("email") != ""); ?>
				<p class="paragraph">Please enter your Email address to recieve a new password</p>
				<div class="control-group <?php if ($error) echo "error"; ?>">
					
					<label class="control-label" for="email">
						Email
					</label>
					<div class="controls">
						<input value="<?php echo $form->value("email"); ?>" type="text" id="email" name="email">
						<?php if ($error) : ?>
							<span class="help-inline"><?php echo $form->error("email"); ?></span>
						<?php endif; ?>
					</div>
				</div>
				
			
			
				<div class="form-actions">
					<button type="submit" class="btn btn-primary">Generate New Password</button>
					<button type="button" class="btn" ><a class="btnLinks" href="mn_main.php">Cancel</a></button>
				</div>
				
				<input type="hidden" name="subforgot" value="1">
			</fieldset>
		</form>
<?php
}
?>

</body>
</html>
